<?php

namespace addons\yunfood\model;

use addons\yunfood\library\ModelTrait;
use think\Model;

/**
 * 通知偏移
 */
class NoticeOffset extends Model
{
    use ModelTrait;

    // 表名,不含前缀
    protected $name = 'yunfood_notice_offset';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = true;

    // 定义时间戳字段名
    protected $updateTime = 'updated_at';
    protected $createTime = 'created_at';

    protected $resultSetType = 'collection';

    // 类型
    const SOURCE_TYPE_NEW_ORDER = 'new_order';

    public static function getSourceTypeList()
    {
        return [self::SOURCE_TYPE_NEW_ORDER => __('新订单')];
    }

    public function getSourceTypeTextAttr($value, $data)
    {
        $optionList = self::getSourceTypeList();

        return $optionList[$data['source_type']] ?? $data['source_type'];
    }
}
